class adapter extends uvm_reg_adapter;
    string tID = get_type_name();

    `uvm_object_utils(adapter)

    function new(string name = "adapter");
        super.new(name);
    endfunction
    
    function uvm_sequence_item reg2bus(const ref uvm_reg_bus_op rw);
        transaction_bus tr;
        tr = new("tr");
        tr.addr = rw.addr;
        tr.bus_op = (rw.kind == UVM_READ) ? BUS_RD : BUS_WR;
        if(tr.bus_op == BUS_WR)
            tr.wr_data = rw.data;
        return tr;
    endfunction

    function void bus2reg(uvm_sequence_item bus_item, ref uvm_reg_bus_op rw);
        transaction_bus tr;
        if(!$cast(tr, bus_item)) begin
            `uvm_fatal(tID, "Provided bus_item is not of the correct type. Expecting bus_trans action")
            return;
        end
        rw.kind = (tr.bus_op == BUS_RD) ? UVM_READ : UVM_WRITE;
        rw.addr = tr.addr;
        rw.byte_en = 'h3;
        rw.data = (tr.bus_op == BUS_RD) ? tr.rd_data : tr.wr_data;
        rw.status = UVM_IS_OK;
    endfunction

endclass
